//
//  UIButton+Extension.m
//  OC_weibo
//
//  Created by apple on 16/4/21.
//  Copyright © 2016年 Apple. All rights reserved.
//

#import "UIButton+Extension.h"

@implementation UIButton (Extension)

///  创建 普通状态 高亮状态 的按钮 方法
+ (UIButton *)buttonWithTitle:(NSString *)title imageName:(NSString *)imageName highlightedImageName:(NSString *)highlightedImageName bgImageName:(NSString *)bgImageName bgHighlightedImageName:(NSString *)bgHighlightedImageName {
    
    UIButton *button = [[UIButton alloc] init];
    
    // 设置按钮文字
    [button setTitle:title forState:UIControlStateNormal];
    // 设置按钮文字颜色
    [button setTitleColor:RGBCOLOR(85, 85, 85) forState:UIControlStateNormal];
    // 设置按钮图片
    [button setImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
    // 设置按钮高亮状态下的图片
    [button setImage:[UIImage imageNamed:highlightedImageName] forState:UIControlStateHighlighted];
    // 设置按钮普通状态背景图片
    [button setBackgroundImage:[UIImage imageNamed:bgImageName] forState:UIControlStateNormal];
    // 设置按钮高亮状态下的背景图片
    [button setBackgroundImage:[UIImage imageNamed:bgHighlightedImageName] forState:UIControlStateHighlighted];
    
    return button;
    
}


///  创建 普通状态 选中状态 的按钮 方法
+ (UIButton *)buttonWithTitle:(NSString *)title imageName:(NSString *)imageName selectedImageName:(NSString *)selectedImageName bgImageName:(NSString *)bgImageName bgselectedImageName:(NSString *)bgselectedImageName {
    
    UIButton *button = [[UIButton alloc] init];
    
    // 设置按钮文字
    [button setTitle:title forState:UIControlStateNormal];
    // 设置按钮文字颜色
    [button setTitleColor:RGBCOLOR(85, 85, 85) forState:UIControlStateNormal];
    // 设置按钮图片
    [button setImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
    // 设置按钮高亮状态下的图片
    [button setImage:[UIImage imageNamed:selectedImageName] forState:UIControlStateHighlighted];
    // 设置按钮普通状态背景图片
    [button setBackgroundImage:[UIImage imageNamed:bgImageName] forState:UIControlStateNormal];
    // 设置按钮高亮状态下的背景图片
    [button setBackgroundImage:[UIImage imageNamed:bgselectedImageName] forState:UIControlStateHighlighted];
    
    return button;
    
}
/// 创建 普通状态 高亮状态 的按钮 方法 (按钮不带高亮状态图片)
+ (UIButton *)buttonWithTitle:(NSString *)title imageName:(NSString *)imageName bgImageName:(NSString *)bgImageName bgHighlightedImageName:(NSString *)bgHighlightedImageName {
    
    UIButton *button = [[UIButton alloc] init];
    
    // 设置按钮文字
    [button setTitle:title forState:UIControlStateNormal];
    // 设置按钮文字颜色
    [button setTitleColor:RGBCOLOR(85, 85, 85) forState:UIControlStateNormal];
    // 设置按钮图片
    [button setImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
    // 设置按钮普通状态背景图片
    [button setBackgroundImage:[UIImage imageNamed:bgImageName] forState:UIControlStateNormal];
    // 设置按钮高亮状态下的背景图片
    [button setBackgroundImage:[UIImage imageNamed:bgHighlightedImageName] forState:UIControlStateHighlighted];
    
    return button;
}

+ (instancetype)buttonWithTitle:(NSString *)title
                normalTextColor:(UIColor *)normalColor
               highlightedColor:(UIColor *)hlightedColor
                   textFontSize:(CGFloat)fontSize {
    UIButton *button = [[UIButton alloc] init];
    
    button.titleLabel.font = [UIFont systemFontOfSize:fontSize];
    [button setTitle:title forState:UIControlStateNormal];
    [button setTitleColor:normalColor forState:UIControlStateNormal];
    [button setTitleColor:hlightedColor forState:UIControlStateHighlighted];
    
    return button;
}
@end
